Passed
Push — master ( 0feaa2...c02782 )
by Dmytro
02:35
created

Reporter.render   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
1
export default class Reporter {
2
    render(report) {
3
        return report;
4
    }
5
6
    merge(renderedReports) {
7
        return renderedReports;
8
    }
9
10
    run(reports, { prettify }) {
11
        return this.merge(
12
            reports.map(({ label, ...r }) => {
13
                const metrics = prettify
14
                    ? this.prettify(prettify, r)
15
                    : r;
16
17
                return this.render({
18
                    label,
19
                    ...metrics
20
                });
21
            })
22
        );
23
    }
24
25
    prettify(prettifier, obj) {
26
        const res = {};
27
28
        for (const key of Object.keys(obj)) {
29
            res[key] = prettifier(obj[key]);
30
        }
31
32
        return res;
33
    }
34
}
35